package com.way.designpatterncodepratice.proxy.other;

import net.sf.cglib.proxy.Enhancer;

/**
 * @author wayleung
 * @description
 * @date 2020-08-12 10:37:19
 */
public class CglibDynamicProxyDemo {
    public static void main(String[] args) {
        Enhancer enhancer = new Enhancer();
        enhancer.setClassLoader(TargetNoInterface.class.getClassLoader());
        enhancer.setSuperclass(TargetNoInterface.class);
        enhancer.setCallback(new MyMethodInterceptor());
        TargetNoInterface proxy = (TargetNoInterface) enhancer.create();
        System.out.println(proxy.getClass().getName());
        proxy.sayHello("way");
    }
}
